<template>
  <div id="app">

    <MyHeader
    :background="'bule'"
    :fontColor="'white'"
    title="TabBar案例"></MyHeader>

    <div class="main">
      <component :is="comName"></component>
    </div>
    <MyTabBar :arr="tabList" @changeCom="changeComFn"></MyTabBar>
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader.vue";
import MyTabBar from "./components/MyTabBar.vue"

import MyGoodsList from "./components/views/MyGoodsList.vue";
import MyGoodsSearch from "./components/views/MyGoodsSearch.vue";
import MyUserInfo from "./components/views/MyUserInfo.vue";

export default {

  data() {
    return {
      comName: "MyGoodsList",
      tabList: [
        {
          iconText: "icon-shangpinliebiao",
          text: "商品列表",
          componentName: "MyGoodsList"
        },
        {
          iconText: "icon-sousuo",
          text: "商品搜索",
          componentName: "MyGoodsSearch"
        },
        {
          iconText: "icon-user",
          text: "我的信息",
          componentName: "MyUserInfo"
        }
      ]
    }
  },
  components: {
    MyTabBar,
    MyHeader,
    MyGoodsList,
    MyGoodsSearch,
    MyUserInfo
  },
  methods: {
    changeComFn(cName) {
      this.comName = cName; // MyTabBar里选出来的组件名赋予给is属性的comName
    }
  }
}

</script>

<style scope>

.main {
  margin-top: 48px;
}

</style>
